package com.jsgt.greekfire.repository

import com.jsgt.greekfire.bean.ActivationBean
import com.jsgt.greekfire.bean.WalletInfoBean
import com.jsgt.greekfire.bean.YTWallet
import com.jsgt.greekfire.common.http.Data
import com.jsgt.greekfire.common.http.ResponseData
import com.jsgt.greekfire.common.http.RetrofitManager
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext


/**
 * author fhx
 * create time 2020/4/24 20:43
 **/
class WalletRepository : BaseRepository() {
    companion object {
        val instance = WalletRepository()
    }
    /**
     * 创建名称
     */
    suspend fun CreateName(params: Map<String, Any>): Data =
        withContext(Dispatchers.IO) {
            RetrofitManager.walletService.CreateName(parseBody(params))
        }
   /**
     * 创建钱包
     */
    suspend fun createWallet(params: Map<String, Any>): ResponseData<YTWallet> =
        withContext(Dispatchers.IO) {
            RetrofitManager.walletService.createWallet(parseBody(params))
        }

    /**
     * 获取钱包信息
     */
    suspend fun getWalletInfo(): ResponseData<WalletInfoBean> =
        withContext(Dispatchers.IO) {
            RetrofitManager.walletService.getWalletInfo()
        }

    /**
     * 导入钱包
     */
    suspend fun importWallet(params: HashMap<String, String>): ResponseData<YTWallet> =
        withContext(Dispatchers.IO) {
            RetrofitManager.walletService.importWallet(parseBody(params))
        }

    /**
     * 验证钱包密码
     */
    suspend fun checkSecurityPassword(params: Map<String, Any>): ResponseData<Any> =
        withContext(Dispatchers.IO) {
            RetrofitManager.walletService.checkSecurityPassword(parseBody(params))
        }

     /**
     * 绑定激活 - 弃用
     */
    suspend fun Bindingactivation(params: Map<String, Any>): ResponseData<Any> =
        withContext(Dispatchers.IO) {
            RetrofitManager.walletService.Bindingactivation(parseBody(params))
        }

    /**
     * 激活列表
     */
    suspend fun activationList(): ResponseData<List<ActivationBean>> =
        withContext(Dispatchers.IO) {
            RetrofitManager.walletService.activationList()
        }

    /**
     * 转账激活其他账户
     */
    suspend fun activationTransfer(params: Map<String, Any>): ResponseData<Any> =
        withContext(Dispatchers.IO) {
            RetrofitManager.walletService.activationTransfer(parseBody(params))
        }

    /**
     * 激活
     */
    suspend fun activation(params: Map<String, Any>): ResponseData<Any> =
        withContext(Dispatchers.IO) {
            RetrofitManager.walletService.activation(parseBody(params))
        }
}